<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加门店仓库</title>
    <link rel="stylesheet" href="__PEAR__/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
            		<div class="layui-form-item">
				  	<div class="layui-card-header">基本资料</div>
				  	</div>
                  <div class="layui-form-item">
				    <label class="layui-form-label">门店编码</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_no" value="{$one['branch_no']}" required  lay-verify="required" placeholder="请输入唯一编码" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">门店名称</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_name"  value="{$one['branch_name']}" required  lay-verify="required" placeholder="请输入门店名称" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">门店类型</label>
				    <div class="layui-input-inline">
				      <select name="trade_type" lay-verify="required" lay-search>
				        <option value=""></option>
				        	<option value="1" {if condition="$one['trade_type'] eq 1"}selected="selected"{/if}>仓库</option>
				        	<option value="2" {if condition="$one['trade_type'] eq 2"}selected="selected"{/if}>加盟店</option>
				       		<option value="3" {if condition="$one['trade_type'] eq 3"}selected="selected"{/if}>总部</option>
				      </select>
				    </div>
				    
				     <label class="layui-form-label">授权码</label>
				    <div class="layui-input-inline">
				      <input type="text" name="authorcode" value="{$one['authorcode']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">联系人</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_man" value="{$one['branch_man']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">电话</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_tel" value="{$one['branch_tel']}"  placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">微信</label>
				    <div class="layui-input-inline">
				      <input type="text" name="wechat" value="{$one['wechat']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">上级经销商</label>
				    <div class="layui-input-inline">
				      <input type="text" name="upername" value="{$one['upername']}"  placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">传真</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_fax" value="{$one['branch_fax']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">电子邮件</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_email" value="{$one['branch_email']}"  placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">营业面积</label>
				    <div class="layui-input-inline">
				      <input type="text" name="branch_mj" value="{$one['branch_mj']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">配送价格</label>
				    <div class="layui-input-inline">
				      <select name="price_type" lay-search>
				        <option value=""></option>
				        <option value="1" {if condition="$one['price_type'] eq 1"}selected="selected"{/if}>进货价</option>
						<option value="2" {if condition="$one['price_type'] eq 2"}selected="selected"{/if}>成本价</option>
						<option value="3" {if condition="$one['price_type'] eq 3"}selected="selected"{/if}>批发价</option>
						<option value="4" {if condition="$one['price_type'] eq 4"}selected="selected"{/if}>配送价</option>
				      </select>
				    </div>
				  </div>
				  
				   <div class="layui-form-item">
				    <label class="layui-form-label">经度</label>
				    <div class="layui-input-inline">
				      <input type="text" name="lon" value="{$one['lon']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">纬度</label>
				    <div class="layui-input-inline">
				      <input type="text" name="lat" value="{$one['lat']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">地址</label>
				    <div class="layui-input-inline">
				      <input type="text" name="address" value="{$one['address']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">备注</label>
				    <div class="layui-input-inline">
				      <input type="text" name="other1" value="{$one['other1']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>

				<div class="layui-form-item">
					<label class="layui-form-label">开启积分</label>
					<div class="layui-input-inline">
						<input type="checkbox" name="use_credit" value="1" title="开启" lay-skin="primary" {if condition="$one['use_credit'] eq '1'"} checked {/if} >
						<div class="layui-inline layui-word-aux">
							会员可使用积分兑换现金
						</div>
					</div>

					<label class="layui-form-label">兑换关系</label>
					<div class="layui-input-inline">
						<input type="text" name="credit_money" value="{$one['credit_money']}" placeholder="" autocomplete="off" class="layui-input">
						<div class="layui-inline layui-word-aux">
							填写整数,多少积分兑换1元
						</div>
					</div>
				</div>
				  
				  <div class="layui-form-item">
				  <div class="layui-card-header">微信商户配置</div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">APPID</label>
				    <div class="layui-input-inline">
				      <input type="text" name="wechat_appid" value="{$one['wechat_appid']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">APPSECRET</label>
				    <div class="layui-input-inline">
				      <input type="text" name="wechat_secret" value="{$one['wechat_secret']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">商家号</label>
				    <div class="layui-input-inline">
				      <input type="text" name="wechat_merchantid" value="{$one['wechat_merchantid']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">支付秘钥</label>
				    <div class="layui-input-inline">
				      <input type="text" name="wechat_paykey" value="{$one['wechat_paykey']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>

				<div class="layui-form-item">
					<label class="layui-form-label">开启</label>
					<div class="layui-input-inline">
						<input type="checkbox" name="use_wechatpay" value="1" title="微信刷卡支付" lay-skin="primary" {if condition="$one['use_wechatpay'] eq '1'"} checked {/if} >
					</div>
				</div>

				<div class="layui-form-item">
					<div class="layui-col-md12">
						<label class="layui-form-label" style="width: 120px;">微信收款二维码</label>
						<div class="layui-input-inline">
							<button type="button" class="layui-btn layui-btn-danger" id="wechatloader"><i class="layui-icon"></i>上传图片</button>
							<img src="{$one['wechat_pay_qrcode']}" width="120" height="auto" id="preview_wechat"/>
							<div class="layui-inline layui-word-aux">
								图片大小限制 {php}echo $image_size/1024; {/php}M
							</div>
						</div>
					</div>
				</div>
				  
				   <div class="layui-form-item">
				  <div class="layui-card-header">支付宝商户配置</div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">APPID</label>
				    <div class="layui-input-inline">
				      <input type="text" name="alipay_appid" value="{$one['alipay_appid']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
				    
				     <label class="layui-form-label">公钥</label>
				    <div class="layui-input-inline">
				      <input type="text" name="alipay_public_key" value="{$one['alipay_public_key']}"  placeholder="" autocomplete="off" class="layui-input">
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				    <label class="layui-form-label">私钥</label>
				    <div class="layui-input-inline">
				      <input type="text" name="alipay_private_key" value="{$one['alipay_private_key']}" placeholder="" autocomplete="off" class="layui-input">
				    </div>
					<label class="layui-form-label">开启</label>
					<div class="layui-input-inline">
					  <input type="checkbox" name="use_alipay" value="1" title="支付宝刷卡支付" lay-skin="primary" {if condition="$one['use_alipay'] eq '1'"} checked {/if} >
					</div>
				  </div>

				<div class="layui-form-item">
					<div class="layui-col-md12">
						<label class="layui-form-label" style="width: 120px;">支付宝收款二维码</label>
						<div class="layui-input-inline">
							<button type="button" class="layui-btn layui-btn-danger" id="alipayloader"><i class="layui-icon"></i>上传图片</button>
							<img src="{$one['alipay_pay_qrcode']}" width="120" height="auto" id="preview_alipay"/>
							<div class="layui-inline layui-word-aux">
								图片大小限制 {php}echo $image_size/1024; {/php}M
							</div>
						</div>
					</div>
				</div>

				<input name="wechat_pay_qrcode" id="wechat_pay_qrcode" type="hidden" value="{$one['wechat_pay_qrcode']}"/>
				<input name="alipay_pay_qrcode" id="alipay_pay_qrcode" type="hidden" value="{$one['alipay_pay_qrcode']}"/>
        		<input name="id" type="hidden" value="{$one['id']}"/>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="branch-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__PEAR__/component/pear/pear.js"></script>
<script>
layui.use(['form','jquery','upload', 'element','layer'],function(){
    let form = layui.form;
    let $ = layui.jquery;
	let upload = layui.upload;
	let element = layui.element;
	let layer = layui.layer;

	var path="{:U('pos/branch','','')}";

	//微信文件上传
	upload.render({
		elem: '#wechatloader'
		,url: path+'/upload' //Super控制器公共接口
		,method: 'post'
		,size: {$image_size} //限制文件大小，单位 KB
		,done: function(res){
			if(res.status==1){
				$("#preview_wechat").attr("src",res.path);
				$("#wechat_pay_qrcode").val(res.path);
				layer.msg('上传成功');
			}else{
				layer.msg('上传失败，请重试');
			}
		}
	});
	//支付宝文件上传
	upload.render({
		elem: '#alipayloader'
		,url: path+'/upload' //Super控制器公共接口
		,method: 'post'
		,size: {$image_size} //限制文件大小，单位 KB
		,done: function(res){
			if(res.status==1){
				$("#preview_alipay").attr("src",res.path);
				$("#alipay_pay_qrcode").val(res.path);
				layer.msg('上传成功');
			}else{
				layer.msg('上传失败，请重试');
			}
		}
	});

	{present name="one"}
	var _url="/branchEdit";
	{else /}
	var _url="/branchAdd";	
	{/present}
    form.on('submit(branch-save)', function(data){
        $.ajax({
            url:path+_url,
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.code){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("branchlist-table");
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>